#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

template  <typename T>
class addN
{
private:
	T addNum;// 这里可以添加其他的类的属性
public:
	addN(const T& a):addNum(a)// 这里是初始化函数列表
	{ // 也可以在这里给addNum赋值
	}
public:
	void operator()(T& p) const
	{
		p += addNum;
	}
};

int main()
{
	vector<int> ivec;
	for (int i = 1; i <= 9; ++i)
	{
		ivec.push_back(i);// ivec.insert(ivec.end(), i);
	}
	//for_each(ivec.begin(), ivec.end(), addN<int>(3));
    for_each(ivec.begin(), ivec.end(), [](int& i) {i += 3; });

	cout << "[ ";
	for (vector<int>::const_iterator iter = ivec.begin(); iter != ivec.end(); ++iter)
	{
		cout << *iter << " ";
	}
	cout << "]" << endl;
	return EXIT_SUCCESS;
}
